/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.TransformerBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class TransformerDAO
/*     */ {
/*  22 */   private static final Log log = LogFactory.getLog(TransformerDAO.class);
/*     */ 
/*  24 */   private dbConnector dbcon = null;
/*  25 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*  26 */   private SimpleDateFormat fresh = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*     */ 
/*     */   private void dbConInit() {
/*  29 */     if (this.dbcon == null)
/*  30 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  34 */     if (this.dbcon != null)
/*  35 */       this.dbcon.closeAll();
/*  36 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getTransformerList(Map condition)
/*     */   {
/*  41 */     ListContentsBFO bfo = new ListContentsBFO();
/*  42 */     int start = Integer.parseInt(condition.get("start").toString());
/*  43 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  44 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  45 */     ResultSet rs = null;
/*  46 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  49 */       dbConInit();
/*  50 */       String strSQL = " select count(id) from transformer where btscode = '" + strBtscode + "' ";
/*  51 */       log.info(strSQL);
/*  52 */       rs = this.dbcon.execQuery(strSQL);
/*  53 */       if (rs.next()) {
/*  54 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  56 */       strSQL = " select * from transformer where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  57 */       log.info(strSQL);
/*  58 */       rs = this.dbcon.execQuery(strSQL);
/*  59 */       while (rs.next()) {
/*  60 */         TransformerBO bo = new TransformerBO();
/*  61 */         bo.setId(rs.getString("id"));
/*  62 */         bo.setBtscode(rs.getString("btscode"));
/*  63 */         bo.setBtsname(rs.getString("btsname"));
/*  64 */         bo.setModel(rs.getString("model"));
/*  65 */         bo.setCapacity(rs.getString("capacity"));
/*  66 */         bo.setManufacturer(rs.getString("manufacturer"));
/*  67 */         bo.setProperty(rs.getString("property"));
/*  68 */         bo.setMaintenance(rs.getString("maintenance"));
/*  69 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  70 */         bo.setMemo(rs.getString("memo"));
/*  71 */         bo.setTranPowerType(rs.getString("tranPowerType"));
/*  72 */         bo.setTranMaintain(rs.getString("tranMaintain"));
/*  73 */         bo.setTranHighLen(rs.getString("tranHighLen"));
/*  74 */         bo.setTranLowLen(rs.getString("tranLowLen"));
/*  75 */         bo.setTranRValue(rs.getString("tranRValue"));
/*  76 */         bo.setTranStartTime(rs.getString("tranStartTime"));
/*  77 */         list.add(bo);
/*     */       }
/*  79 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  82 */       e.printStackTrace();
/*  83 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  86 */       dbConClose();
/*     */     }
/*  88 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean saveTransformerBO(TransformerBO bo)
/*     */   {
/*  94 */     log.info("添加--变压器---开始");
/*  95 */     boolean flag = true;
/*     */     try
/*     */     {
/*  98 */       dbConInit();
/*  99 */       StringBuffer sqlBuf = new StringBuffer();
/* 100 */       sqlBuf.append(" insert into transformer ( btscode, btsname, model,  capacity,");
/* 101 */       sqlBuf.append(" manufacturer, property, maintenance, refreshtime,  memo,");
/* 102 */       sqlBuf.append(" tranPowerType, tranMaintain, tranHighLen, tranLowLen,");
/* 103 */       sqlBuf.append(" tranRValue, registtime,tranStartTime  ) values ( ");
/* 104 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/* 105 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/* 106 */       sqlBuf.append(" '" + bo.getModel() + "' ,");
/* 107 */       sqlBuf.append(" '" + bo.getCapacity() + "' ,");
/* 108 */       sqlBuf.append(" '" + bo.getManufacturer() + "' ,");
/* 109 */       sqlBuf.append(" '" + bo.getProperty() + "' ,");
/* 110 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/* 111 */       sqlBuf.append(" '" + this.fresh.format(new Date()) + "' ,");
/* 112 */       sqlBuf.append(" '" + bo.getMemo() + "' , ");
/* 113 */       sqlBuf.append(" '" + bo.getTranPowerType() + "' ,");
/* 114 */       sqlBuf.append(" '" + bo.getTranMaintain() + "' ,");
/* 115 */       sqlBuf.append(" '" + bo.getTranHighLen() + "' ,");
/* 116 */       sqlBuf.append(" '" + bo.getTranLowLen() + "' ,");
/* 117 */       sqlBuf.append(" '" + bo.getTranRValue() + "' ,");
/* 118 */       sqlBuf.append(" '" + this.open.format(new Date()) + "' ,");
/* 119 */       sqlBuf.append(" '" + bo.getTranStartTime() + "' )");
/* 120 */       log.info(sqlBuf.toString());
/* 121 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 125 */       flag = false;
/* 126 */       e.printStackTrace();
/* 127 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 130 */       dbConClose();
/*     */     }
/* 132 */     log.info("添加--变压器---结束");
/* 133 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateTransformerBO(TransformerBO bo)
/*     */   {
/* 139 */     log.info("修改--变压器---开始");
/* 140 */     boolean flag = true;
/*     */     try
/*     */     {
/* 143 */       dbConInit();
/* 144 */       StringBuffer sqlBuf = new StringBuffer();
/* 145 */       sqlBuf.append(" update  transformer set ");
/* 146 */       sqlBuf.append(" model = '" + bo.getModel() + "' ,");
/* 147 */       sqlBuf.append(" capacity = '" + bo.getCapacity() + "' ,");
/* 148 */       sqlBuf.append(" manufacturer = '" + bo.getManufacturer() + "' ,");
/* 149 */       sqlBuf.append(" property = '" + bo.getProperty() + "' ,");
/* 150 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/* 151 */       sqlBuf.append(" refreshtime = '" + this.fresh.format(new Date()) + "' ,");
/* 152 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' , ");
/* 153 */       sqlBuf.append(" tranPowerType = '" + bo.getTranPowerType() + "' ,");
/* 154 */       sqlBuf.append(" tranMaintain = '" + bo.getTranMaintain() + "' ,");
/* 155 */       sqlBuf.append(" tranHighLen = '" + bo.getTranHighLen() + "' ,");
/* 156 */       sqlBuf.append(" tranLowLen = '" + bo.getTranLowLen() + "' ,");
/* 157 */       sqlBuf.append(" tranRValue = '" + bo.getTranRValue() + "' ,");
/* 158 */       sqlBuf.append(" tranStartTime = '" + bo.getTranStartTime() + "' ");
/* 159 */       sqlBuf.append(" where id = '" + bo.getId() + "'");
/* 160 */       log.info(sqlBuf.toString());
/* 161 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 165 */       flag = false;
/* 166 */       e.printStackTrace();
/* 167 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 170 */       dbConClose();
/*     */     }
/* 172 */     log.info("修改--变压器---结束");
/* 173 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteTransformerBO(String strID)
/*     */   {
/* 178 */     log.info("删除--变压器---开始");
/* 179 */     boolean flag = true;
/*     */     try
/*     */     {
/* 182 */       dbConInit();
/* 183 */       StringBuffer sqlBuf = new StringBuffer();
/* 184 */       sqlBuf.append(" delete from   transformer  ");
/* 185 */       sqlBuf.append(" where id = '" + strID + "'");
/* 186 */       log.info(sqlBuf.toString());
/* 187 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 191 */       flag = false;
/* 192 */       e.printStackTrace();
/* 193 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 196 */       dbConClose();
/*     */     }
/* 198 */     log.info("删除--变压器---结束");
/* 199 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getTransformerByBtsName(Map condition)
/*     */   {
/* 204 */     ListContentsBFO bfo = new ListContentsBFO();
/* 205 */     int start = Integer.parseInt(condition.get("start").toString());
/* 206 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 207 */     String strBtsName = condition.get("btsName").toString();
/* 208 */     ResultSet rs = null;
/* 209 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 212 */       dbConInit();
/* 213 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 214 */       Object objRegistEndTime = condition.get("registEndTime");
/* 215 */       String strSQL = " select count(id) from transformer where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 216 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 217 */       log.info(strSQL);
/* 218 */       rs = this.dbcon.execQuery(strSQL);
/* 219 */       if (rs.next()) {
/* 220 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 222 */       strSQL = " select * from transformer where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 223 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 224 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 225 */       log.info(strSQL);
/* 226 */       rs = this.dbcon.execQuery(strSQL);
/* 227 */       while (rs.next()) {
/* 228 */         TransformerBO bo = new TransformerBO();
/* 229 */         bo.setId(rs.getString("id"));
/* 230 */         bo.setBtscode(rs.getString("btscode"));
/* 231 */         bo.setBtsname(rs.getString("btsname"));
/* 232 */         bo.setModel(rs.getString("model"));
/* 233 */         bo.setCapacity(rs.getString("capacity"));
/* 234 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 235 */         bo.setProperty(rs.getString("property"));
/* 236 */         bo.setMaintenance(rs.getString("maintenance"));
/* 237 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 238 */         bo.setMemo(rs.getString("memo"));
/* 239 */         bo.setTranPowerType(rs.getString("tranPowerType"));
/* 240 */         bo.setTranMaintain(rs.getString("tranMaintain"));
/* 241 */         bo.setTranHighLen(rs.getString("tranHighLen"));
/* 242 */         bo.setTranLowLen(rs.getString("tranLowLen"));
/* 243 */         bo.setTranRValue(rs.getString("tranRValue"));
/* 244 */         bo.setTranStartTime(rs.getString("tranStartTime"));
/* 245 */         list.add(bo);
/*     */       }
/* 247 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 250 */       e.printStackTrace();
/* 251 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 254 */       dbConClose();
/*     */     }
/* 256 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 262 */     ResultSet rs = null;
/* 263 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 266 */       dbConInit();
/* 267 */       String strSQL = " select * from transformer where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' )  ";
/* 268 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 269 */       log.info(strSQL);
/* 270 */       rs = this.dbcon.execQuery(strSQL);
/* 271 */       while (rs.next()) {
/* 272 */         TransformerBO bo = new TransformerBO();
/* 273 */         bo.setId(rs.getString("id"));
/* 274 */         bo.setBtscode(rs.getString("btscode"));
/* 275 */         bo.setBtsname(rs.getString("btsname"));
/* 276 */         bo.setModel(rs.getString("model"));
/* 277 */         bo.setCapacity(rs.getString("capacity"));
/* 278 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 279 */         bo.setProperty(rs.getString("property"));
/* 280 */         bo.setMaintenance(rs.getString("maintenance"));
/* 281 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 282 */         bo.setMemo(rs.getString("memo"));
/* 283 */         bo.setTranPowerType(rs.getString("tranPowerType"));
/* 284 */         bo.setTranMaintain(rs.getString("tranMaintain"));
/* 285 */         bo.setTranHighLen(rs.getString("tranHighLen"));
/* 286 */         bo.setTranLowLen(rs.getString("tranLowLen"));
/* 287 */         bo.setTranRValue(rs.getString("tranRValue"));
/* 288 */         bo.setTranStartTime(rs.getString("tranStartTime"));
/* 289 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 293 */       e.printStackTrace();
/* 294 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 297 */       dbConClose();
/*     */     }
/* 299 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.TransformerDAO
 * JD-Core Version:    0.6.2
 */